<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>牧心农业</title>
    <link rel="stylesheet" type="text/css" href="/static/css/eui.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/mobile.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/iconfont.css" />
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/doT.min.js"></script>
    <script src="/static/js/func.js"></script>
</head>
<body>
    <div class="content margin_top">
        <header class="header fixed_top bg_mx_green"></header>
        <form class="regist_sale"></form>
    </div>
    <div class="toast"></div>
    <!-- toast模版 -->
    <script type="text/template" charset="utf-8" id='toast_template'>
        <i class="iconfont icon-toast{{=it.icon}}"></i>
        <div class="toast_text">{{=it.text}}</div>
    </script>
    <script type="text/template" charset="utf-8" id='info_template'>
        <div class="bg_white margin_b_10">
            <div class="flex border_b padding_10_15 border_b">
                <div class="width_70">出栏原因</div>
                <div class="left_70 light">
                    <select name="reason">
                        <{foreach from=$outreason key=k item=value }>
                            <option value="<{$value}>"><{$value}></option>
                        <{/foreach}>
                    </select>
                </div>
            </div>
            <div class="text_info padding_10_15">
                <textarea name="descripation" placeholder="请输入出栏原因描述" request title="出栏原因描述"></textarea>
            </div>
        </div>
        <!--<div class="margin_b_10 block_center flex text_center border_mx_green lineheight_3" style="width:60%;">-->
            <!--<div class="flex_1 bg_mx_green kill_style" data-n="0">{{=it[0].title}}</div>-->
            <!--<div class="flex_1 bg_white kill_style" data-n="1">{{=it[1].title}}</div>-->
            <!--<input type="hidden" name="killtype" value="{{=it[0].title}}">-->
            <!--<input type="hidden" name="killprice" value="{{=it[0].price}}">-->
            <!--<input type="hidden" name="pigid">-->
        <!--</div>-->
        <!--<div class="kill_style1">-->
            <!--<div class="bg_white padding_10_15 margin_b_10">{{=it[0].desc}}</div>-->
            <!--<div class="bg_white padding_10_15 margin_b_10 lineheight_3">宰杀费(元) {{=it[0].price}}</div>-->
        <!--</div>-->
        <!--<div class="kill_style2 hide">-->
            <!--<div class="bg_white padding_10_15 margin_b_10 ">{{=it[1].desc}}</div>-->
            <!--<div class="bg_white padding_10_15 margin_b_10 lineheight_3">宰杀费(元) {{=it[1].price}}</div>-->
        <!--</div>-->
        <div class="padding_15 font_16">
            <button class="btn btn_mx_green all_width lineheight_3">保存</button>
        </div>
        <input type="hidden" name="pigid">
        <input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
    </script>
    <script>
        // 页面初始化
            var info = <{$info}>;
            console.log(info);
            var evalToast = doT.template($("#toast_template").text());
            var evalinfo = doT.template($("#info_template").text());
            loaddata(".regist_sale",evalinfo,info);
//            $(".kill_style").click(function(){
//                var n = $(this).data("n");
//                $(".kill_style").toggleClass("bg_mx_green bg_white");
//                $(".kill_style1,.kill_style2").toggle()
//                $("input[name=killtype]").val(info[n].title)
//                $("input[name=killprice]").val(info[n].price)
//            })
            loadheadbar("出栏登记",1)
        // 提交表单
            var submited = false;
            $(".regist_sale").submit(function(e){
                e.preventDefault();
                var pigid = GetQueryString("pigid");
                $("input[name=pigid]").val(pigid)
                with(this){
                    for (var i = 0; i < this.length; i++) {
                        if($(this[i]).attr("request")==""){
                            if(!checkone(this[i])){
                                return false;
                            }
                        }
                    }
                    if(submited) return false;
                    var data = $(".regist_sale").serialize();
                    $.post("/business/person/post-pig-out",data,function(res){console.log(res)
                        submited = true;
                        toast("attention",res.msg);
                        if(!res.status){
                            location.href='/business/person/pig';
                        }
                    },"json")
                }
            })
    </script>
</body>
</html>
